import Joi from "joi";

// 单文件上传验证
export const uploadFileSchema = Joi.object({
  type: Joi.string()
    .valid("image", "video", "document", "other")
    .default("other"),
});

// 分片上传初始化验证
export const initChunkUploadSchema = Joi.object({
  fileHash: Joi.string().length(32).required(),
  fileName: Joi.string().max(255).required(),
  fileSize: Joi.number().integer().positive().required(),
  fileType: Joi.string().required(),
  totalChunks: Joi.number().integer().min(1).required()
});

// 分片上传验证
export const uploadChunkSchema = Joi.object({
  fileHash: Joi.string().required(),
  chunkHash: Joi.string().required(),
  chunkIndex: Joi.number().integer().min(0).required(),
  fileName: Joi.string().optional(),
  totalChunks: Joi.number().integer().min(1).optional(),
  fileSize: Joi.number().integer().positive().required(),
});

// 合并分片验证
export const mergeChunksSchema = Joi.object({
  fileHash: Joi.string().uuid().required(),
  fileName: Joi.string().optional(),
  fileSize: Joi.number().integer().positive().required(),
});
